package com.kingbi.system.people.dao;

import java.util.ArrayList;

import com.kingbi.system.people.model.PeopleModel;

public class PeopleQuery
{
    StringBuilder search_query_bud;

    StringBuilder search_count_bud;

    StringBuilder temp_bud;
    
    Object[] params ;
    
    ArrayList paramList;

    public PeopleQuery()
    {
        super();
        this.search_query_bud = new StringBuilder();
        this.search_count_bud = new StringBuilder();
        search_query_bud
                .append("from com.kingbi.system.people.model.PeopleModel people where 1=1");
        search_count_bud
                .append("select count(*) from com.kingbi.system.people.model.PeopleModel people where 1=1");
    }

    public PeopleQuery(StringBuilder search_query_bud, StringBuilder search_count_bud,
            StringBuilder temp_bud)
    {
        super();
        this.search_query_bud = new StringBuilder();
        this.search_count_bud = new StringBuilder();
        search_query_bud
                .append("from com.kingbi.system.people.model.PeopleModel people where 1=1");
        search_count_bud
                .append("select count(*) from com.kingbi.system.people.model.PeopleModel people where 1=1");
    }

    public void doSearchQuery(PeopleModel peopleModel)
    {
        temp_bud = new StringBuilder();
        paramList = new ArrayList();

    if(peopleModel.getUserName()!=null &&  !peopleModel.getUserName().equals("") && !peopleModel.getUserName().equals("null")) 
    { 
        temp_bud.append(" and people.userName like ?"); 
         paramList.add('%'+peopleModel.getUserName().trim()+'%');
    } 



        if(paramList!=null && paramList.size()>0)
        {
            params = new Object[paramList.size()];
            for(int i=0;i<paramList.size();i++)
            {
                params[i] = paramList.get(i);
            }
        }
        
        if(temp_bud!=null && temp_bud.length()>0)
        {
            search_query_bud.append(temp_bud.toString());
            search_count_bud.append(temp_bud.toString());
        }
       
       search_query_bud.append(" order by people"+"."+"userId desc");
    }

    public StringBuilder getSearch_query_bud()
    {
        return search_query_bud;
    }

    public void setSearch_query_bud(StringBuilder search_query_bud)
    {
        this.search_query_bud = search_query_bud;
    }

    public StringBuilder getSearch_count_bud()
    {
        return search_count_bud;
    }

    public void setSearch_count_bud(StringBuilder search_count_bud)
    {
        this.search_count_bud = search_count_bud;
    }

    public StringBuilder getTemp_bud()
    {
        return temp_bud;
    }

    public void setTemp_bud(StringBuilder temp_bud)
    {
        this.temp_bud = temp_bud;
    }

    public Object[] getParams()
    {
        return params;
    }

    public void setParams(Object[] params)
    {
        this.params = params;
    }

    
   
}